package cs236369.webserver.typehandler;

import java.util.HashMap;
import java.util.Map;

public class Session {
	
	Map<String,Object> session = new HashMap<String,Object>();
	private boolean createCookie = false;
	
	public void set(String name,Object val) {
		
		// we should add the cookie header
		if(session.isEmpty()) {
			createCookie = true;
		}
		
		session.put(name, val);
		
	}
	
	public Object get(String name) {

		return session.get(name);
	}
	
	public void invalidate() {
		session.clear();
		
	}
	
	public boolean toSet() {
		boolean toSet = createCookie;
		createCookie = false;
		return toSet;
	}
}
